﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Data;

namespace hostal
{
    public partial class Form1 : Form
    {
        private string usuario, tipoUsuario;
        public Form1()
        {
            InitializeComponent();
        }

        public Form1(string usuario,string tipoUsuario)
        {
            InitializeComponent();
            this.usuario = usuario;
            this.tipoUsuario = tipoUsuario;
            if (tipoUsuario=="recepcionista")
            {
                cuentasToolStripMenuItem1.Visible = false;
            }
        }

        private void callForms(Form form)
        {
            if (this.MdiChildren.Length > 0)
                this.MdiChildren[0].Close();
            form.MdiParent = this;
            form.Show();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            if (tipoUsuario == "recepcionista")
            {
                cuentasToolStripMenuItem1.Visible = false;
            }
        }

        private void registrarHabitacionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RegistrarHabitacion win = new RegistrarHabitacion();
            callForms(win);
        }

        private void buscarHabitacionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BuscarHabitacion win = new BuscarHabitacion();
            callForms(win);
        }

        private void registrarHabitacionToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            RegistrarHabitacion win = new RegistrarHabitacion();
            callForms(win);
        }

        private void buscarHabitacionToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            BuscarHabitacion win = new BuscarHabitacion();
            callForms(win);
        }

        private void registrarNuevaCuentaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RegistrarCuenta win = new RegistrarCuenta();
            callForms(win);
        }

        private void buscarCuentaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BuscarCuenta win = new BuscarCuenta(tipoUsuario,usuario);
            callForms(win);
        }

        private void editarDatosToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PersonalDataAccess verInformacion = new PersonalDataAccess();
            CuentasDataAccess obtenerNumeroDocumento = new CuentasDataAccess();
            EditarCuenta m = new EditarCuenta(verInformacion.buscarTodosDatos(obtenerNumeroDocumento.obtenerNumeroDocumento(usuario)), usuario, "si", tipoUsuario, tipoUsuario);
            /*if (this.MdiChildren.Length > 0)
                this.MdiChildren[0].Close();
            m.MdiParent = this;
            m.Show();
            usuario = m.usuario;*/
            if (m.ShowDialog() == DialogResult.OK)
            {
                if (m.cuentaActivaBoleano)
                {
                    usuario = m.usuario;
                    tipoUsuario = m.tipoUsuario;
                    Form1_Load(sender, e);
                }
                else
                    this.Close();
            }
            //Form1_Load(sender, e);
            //this.Close();
        }

        private void cambiarPasswordToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CambiarPassword win = new CambiarPassword(usuario);
            callForms(win);
        }

        private void registrarReservaToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            RegistrarReserva win = new RegistrarReserva();
            callForms(win);
        }

        private void buscarReservaToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            BuscarReserva win = new BuscarReserva();
            callForms(win);
        }

        private void registrarIngresoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RegistrarIngreso win = new RegistrarIngreso();
            callForms(win);
        }

        private void registrarClienteToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            registarCliente win = new registarCliente();
            callForms(win);
        }

        private void buscarClienteToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            BuscarCliente win = new BuscarCliente();
            callForms(win);
        }

        private void buscarHospedajeToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            BuscarHospedaje win = new BuscarHospedaje();
            callForms(win);
        }

        private void registrarProductoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RegistrarProducto win = new RegistrarProducto();
            callForms(win);
        }

        private void buscarProductoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BuscarProducto win = new BuscarProducto();
            callForms(win);
        }

        private void limpiezaToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            Limpieza win = new Limpieza();
            callForms(win);
        }

        private void registrarSalidaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            /*BuscarHospedaje win = new BuscarHospedaje("si");
            callForms(win);*/
            RegistrarSalida win = new RegistrarSalida();
            callForms(win);
        }

        private void frigobarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Frigobar win = new Frigobar();
            callForms(win);
        }

        private void gestionConsumosToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GestionConsumo win = new GestionConsumo();
            callForms(win);
        }

        private void ingresoConReservaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BuscarReserva ingresoReserva = new BuscarReserva("registro");
            callForms(ingresoReserva);
        }

        private void reportesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
        }

        private void personasHospedadasToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ReporteHospedados reportes = new ReporteHospedados();
            callForms(reportes);
        }

        private void reservasRealizadasToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ReporteReservas reportes = new ReporteReservas();
            callForms(reportes);
        }

        private void consumosToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ReporteConsumos reportes = new ReporteConsumos();
            callForms(reportes);
        }
      
    }
}
